package org.practice.proxy.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

//该类用来封装proxy对象的业务逻辑,表示代理对象所能做的事情,相当于struts2的拦截器
public class BusinessInvocationHandler implements InvocationHandler{
	private Object targetObj;
	public BusinessInvocationHandler(Object target){
		this.targetObj=target;
	}
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		
		// .......织入代码开始...........
		System.out.println("方法名="+method.getName());
		System.out.println("proxy="+proxy.getClass().getName());
		System.out.println("proxy do something。。。");
		// .......织入代码结束...........
		method.invoke(targetObj, args);
		return null;
	}
	
}
